var addTag = function addTag(data, myTag) {

	switch (myTag) {
	case "bold":
		var beginTag = "<b>";
		var endTag = "</b>";
		break;
	
	case "italic":
		var beginTag = "<i>";
		var endTag = "</i>";
		break;
		
	case "underline":
		var beginTag = "<u>";
		var endTag = "</u>";
		break;

	case "header1":
		var beginTag = "<h1>";
		var endTag = "</h1>";
		break;
		
	case "header2":
		var beginTag = "<h2>";
		var endTag = "</h2>";
		break;
		
	case "header3":
		var beginTag = "<h3>";
		var endTag = "</h3>";
		break;
	
	case "paragraph":
		var beginTag = "<p>";
		var endTag = "</p>";
		break;
	default:
		var beginTag = "";
		var endTag = "";
		break;
	}

	var myArea = document.getElementById("userForm:inputTextArea");
	var begin, selection, end;
	if (data.status == "success") {
		if (myArea.selectionStart != undefined) {
			begin = myArea.value.substr(0, myArea.selectionStart);
			selection = myArea.value.substr(myArea.selectionStart,
					myArea.selectionEnd - myArea.selectionStart);
			end = myArea.value.substr(myArea.selectionEnd);
			if (selection.length > 0) {
				myArea.value = begin + beginTag + selection + endTag + end;
			} else {
				myArea.value = begin + beginTag + endTag + end;
			}
			myArea.focus();
		}
	}

};